package com.study.controller;

import com.study.pojo.Video;
import com.study.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/v1/video")
public class VideoController {

    @Autowired
    private VideoService videoService;

    //根据ID查询视频
    @GetMapping("/find_by_id")
    public Object findById(int videoId, HttpServletRequest request){
        System.out.println("视频服务：" + request.getServerName() + "：" + request.getServerPort());
        return videoService.findById(videoId);
    }

    //插入 - 此处参数为了方便，只传了一个id
    @PostMapping("/insert")
    public void insert(@RequestBody Video video){
        //为了方便，只是打印了一下参数
        System.out.println("视频标题：" + video.getTitle());
    }

}
